﻿using AutoMapper;
using Modules.Project;
using PmSoft;

namespace ManagementApi.Models.Manage.ProjectSecurityDeposit
{
    public class ProjectSecurityDepositDto
    {
        /// <summary>
        /// 主键 
        ///</summary>
        public int Id { get; set; }
        /// <summary>
        /// 项目id 
        ///</summary>
        public int ProjectId { get; set; }
        /// <summary>
        /// 流水号 
        ///</summary>
        public string SerialNumber { get; set; }
        /// <summary>
        /// 缴纳主体名称 
        ///</summary>
        public string Name { get; set; }
        /// <summary>
        /// 缴纳主体统一社会信用代码 
        ///</summary>
        public string Code { get; set; }
        /// <summary>
        /// 银行是否对账户设置特殊标识 
        ///</summary>
        public bool Identifying { get; set; }
        /// <summary>
        /// 是否已退还 
        ///</summary>
        public bool IsRefund { get; set; }
        /// <summary>
        /// 退还金额 
        ///</summary>
        public decimal? RefundAmount { get; set; }
        /// <summary>
        /// 退还日期 
        ///</summary>
        public DateTime? RefundDate { get; set; }
        /// <summary>
        /// 退还决定单位名称 
        ///</summary>
        public string RefundCorpName { get; set; }
        /// <summary>
        /// 退还决定单位统一社会信用代码 
        ///</summary>
        public string RefundCorpCode { get; set; }
        /// <summary>
        /// 动用通知文书号 
        ///</summary>
        public string InstrumentNumber { get; set; }
        /// <summary>
        /// 是否已核实 
        ///</summary>
        public bool? IsVerify { get; set; }
        /// <summary>
        /// 核实结论(1通过,-1不通过) 
        ///</summary>
        public 核实结论? VirifyConclusion { get; set; }
        /// <summary>
        /// 核实结论(1通过,-1不通过) 
        ///</summary>
        public string? VirifyConclusionName { get; set; }
        /// <summary>
        /// 结论说明(不通过原因   为不通过时必填) 
        ///</summary>
        public string? VirifyInstructions { get; set; }
        /// <summary>
        /// 已核实时间 
        ///</summary>
        public DateTime? VerifyTime { get; set; }
        /// <summary>
        /// 创建时间 
        ///</summary>
        public DateTime CreateTime { get; set; }
    }

    public static partial class ProjectSecurityDepositExceptions
    {
        public static ProjectSecurityDepositDto AsDto(this Modules.ProjectSecurityDeposit entity)
        {
            ProjectSecurityDepositDto dto = new ProjectSecurityDepositDto();
            var mapper = ServiceAccessor.GetService<IMapper>();
            mapper.Map(entity, dto);
            dto.VirifyConclusionName = entity.VirifyConclusion?.GetDescription();
            return dto;
        }

        /// <summary>
        /// 下拉列表
        /// </summary>
        /// <param name="projectInfo"></param>
        /// <returns></returns>
        public static LabelValue<int> AsPullDownDto(this Modules.ProjectSecurityDeposit projectSecurityDeposit)
        {
            LabelValue<int> data = new LabelValue<int>();
            data.Value = projectSecurityDeposit.Id;
            data.Label = projectSecurityDeposit.Code;
            return data;
        }
    }
}
